{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>题目列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                    <div class="input-group" >  
                        <a href="{:url('add_questions')}" style="margin-right: 10px;"><button class="btn btn-primary" type="button">添加题目</button></a> 
                        <a href="{:url('questions/setting')}"><button class="btn btn-primary" type="button">导入题目</button></a> 
                    </div>                                                                  
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th width="2%"><input class="i-checks checkbox check-all" type="checkbox"></th>
                                <th>ID</th>
                                <th>科目名称</th>
                                <th>标题</th>
                                <th>答案</th>
                                <th>段位</th>
                                <th>题目来源</th>
                                <th>提交者</th>
                                 <th width="3%">选择正确(次)</th>
                                 <th width="3%">选择错误(次)</th>
                                 <th width="3%">选项一(次)</th>
                                 <th width="3%">选项二(次)</th>
                                 <th width="3%">选项三(次)</th>
                                 <th width="3%">选项四(次)</th>
                                <th>状态</th>
                                <th width="10%">添加时间</th>
                                <th width="10%">操作</th>
                            </tr>
                        </thead>
                        <tbody id="article_list">
                            {foreach name="lists" item="vo"}
                                <tr class="long-td">
                                    <td><input class="ids i-checks"  id="check_{$vo.id}" type="checkbox" name="ids[]" value="{$vo.id}"></td>
                                    <td>{$vo.id}</td>
                                    <td>{$vo.name}</td>
                                    <td>{$vo.title}</td> 
                                    <td>
                                        {if condition="@$vo.answer"}
                                        {foreach $vo.answer as $an}
                                        <span>{$an.name}、</span>
                                        {/foreach}
                                        {/if}
                                    </td>
                                    <td>{$vo.grad_id}</td>
                                    <td>{if condition="@$vo.source_type eq 1"}用户提交{else}默认系统{/if}</td> 

                                    <td>{$vo.user_name}</td> 
                                    <td>{$vo.right_num}</td>
                                    <td>{$vo.error_num}</td>
                                    <td>{$vo.answer1_num}</td>
                                    <td>{$vo.answer2_num}</td>
                                    <td>{$vo.answer3_num}</td>
                                    <td>{$vo.answer4_num}</td>
                                    <td>
                                        {if condition="$vo['status'] == 0"}
                                           
                                             <div id="zt{$vo.id}"><span class="label label-info">审核中</span></div>
                                            
                                        {elseif condition="$vo['status'] == 1"}
                                           
                                             <div id="zt{$vo.id}"><span class="label label-info">已通过</span></div>
                                           
                                        {else/}   
                                             <div id="zt{$vo.id}"><span class="label label-danger">未通过</span></div>
                                            
                                        {/if}   
                                    </td>
                                    <td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
                                    <td>
                                        <a href="{:url('edit_questions',['id'=>$vo.id])}" class="btn btn-primary btn-xs">
                                            <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;
                                        <a href="javascript:;" onclick="del_questions({$vo.id})" class="btn btn-danger btn-xs">
                                            <i class="fa fa-trash-o"></i> 删除</a>   
                                    </td>
                                </tr>
                            {/foreach}
                        </tbody>
                    </table>
                </div>
                <div class="btn-group" style="display:inline;">
                    <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle">操作
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" style="left:0;top: 35px;">
                        <li>
                            <a href="javascript:;" class="sel" data-status="1">审核通过</a>
                            <a href="javascript:;" class="sel" data-status="2">审核不通过</a>
                        </li>
                    </ul>
                </div>
                <!-- 分页 -->
                <div id="Pages">  {$page} </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}


<script type="text/javascript">
    function del_questions(id){
        layer.confirm('确认删除此数据?', {icon: 3, title:'提示'}, function(index){
            //do something
            $.getJSON("{:url('del_questions')}", {'id' : id}, function(res){
                if(res.code == 1){
                    layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
                        window.location.href="{:url('questions/index')}";
                    });               
                }else{
                    layer.msg(res.msg,{icon:0,time:1500,shade: 0.1});
                }
            });

            layer.close(index);
        })

    }

    $('.sel').click(function(){
        
        var params = $('.checked').find('input').serialize();
        var status = $(this).data('status');
        params =  params + "&status="+status;
        $.post("{:url('questions_auth')}", params, function(res){
            layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
                window.location.reload(true);
            });
        });
        
    })

</script>
</body>
</html>